/*
 * Copyright 2010, 2011, 2012 mapsforge.org
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.plako.mapper;

import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * A simple start screen for the sample activities.
 */
public class MainActivity extends Activity {
	public static String login;
	public static String missionCode;

	private Button createButton(final Class<?> clazz) {
		Button button = new Button(this);
		button.setText("Offline Mode");
		button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {

				if (login == null)
					startActivity(new Intent(MainActivity.this, LoginActivity.class));
				else {
					Intent intent = new Intent(MainActivity.this, clazz);
					Bundle bundle = new Bundle();
					Calendar calendar = Calendar.getInstance();
					missionCode = login + "-" + calendar.get(Calendar.DATE) + "-" + calendar.get(Calendar.MONTH) + "-"
							+ calendar.get(Calendar.YEAR);

					Log.i("missioncode", missionCode);

					bundle.putString("login", login);
					intent.putExtras(bundle);

					startActivity(intent);
				}
			}
		});
		return button;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle b = getIntent().getExtras();
		login = b.getString("login");
		Log.i("user", login + " connected");
		// setContentView(R.layout.activity_main_activity);
		// LinearLayout linearLayout = (LinearLayout) findViewById(R.id.samples);
		//
		// linearLayout.addView(createButton(OverlayMapViewer.class));

	}
}
